﻿using System.ComponentModel.Design;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Simple.Services;
using Simple.Services.System.QHSEViolationCategory.Models;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 隐患类别管理
/// </summary>
[Route("QHSEDangerCategory/[action]")]
[ApiController]
public class QHSEDangerCategoryController : ControllerBase
{
    private readonly QHSEDangerCategoryService _dangerCategoryService;

    public QHSEDangerCategoryController(QHSEDangerCategoryService dangerCategoryService)
    {
        _dangerCategoryService = dangerCategoryService;
    }

    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> List()
    {
        List<QHSEDangerCategoryModel> menus = await _dangerCategoryService.GetAsync();
        return AppResult.Status200OK(data: menus);
    }
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> Page([FromQuery] QHSEDangerCategoryPageInputModel model)
    {
        PageResultModel<QHSEDangerCategoryModel> data = await _dangerCategoryService.GetPageAsync(model);
        return AppResult.Status200OK(data: data);
    }
    /// <summary>
    /// 隐患类别树
    /// </summary>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<AppResult> DangerTree()
    {
        List<AntTreeNode> data = await _dangerCategoryService.GetCategoryTreeAsync();
        return AppResult.Status200OK(data: data);
    }
    [HttpGet]
    [ValidateTimestampAndSignature]
    public async Task<AppResult> DangerTree1()
    {
        List<AntTreeNode> data = await _dangerCategoryService.GetCategoryTreeAsync();
        return AppResult.Status200OK(data: data);
    }
}
